package com.mls.fivedistrict.controller.portal;

import com.github.pagehelper.PageInfo;
import com.mls.fivedistrict.common.PageFilter;
import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.controller.BaseController;
import com.mls.fivedistrict.pojo.Calculate;
import com.mls.fivedistrict.pojo.Integral;
import com.mls.fivedistrict.pojo.User;
import com.mls.fivedistrict.server.CalculateService;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Created by chenxiuxiang on 2018/4/6.
 */
@RestController("pertalCalculateController")
@RequestMapping("/api/app")
public class CalculateController extends BaseController {

    @Resource(name = "calculateService")
    CalculateService calculateService;


    @GetMapping("/v1/calculates")
    public ServiceResponse getCalculateList(HttpServletRequest httpServletRequest) {
        User user = getUser();
        PageFilter pageFilter = getPageFilter();
        pageFilter.getFilterMap().put("userId", user.getId() + "");
        pageFilter.setOrderCause("create_date desc");
        List<Calculate> calculateList = calculateService.getCalculateList(pageFilter);
        PageInfo pageInfo = new PageInfo(calculateList, 5);
        return ServiceResponse.createSuccessResponse(pageInfo);
    }


}
